import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FrontUserVO, FrontUserForm, FrontUserQuery } from '@/api/front/frontUser/types';

/**
 * 查询前台用户列表
 * @param query
 * @returns {*}
 */

export const listFrontUser = (query?: FrontUserQuery): AxiosPromise<FrontUserVO[]> => {
  return request({
    url: '/front/frontUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询前台用户详细
 * @param userId
 */
export const getFrontUser = (userId: string | number): AxiosPromise<FrontUserVO> => {
  return request({
    url: '/front/frontUser/' + userId,
    method: 'get'
  });
};

/**
 * 新增前台用户
 * @param data
 */
export const addFrontUser = (data: FrontUserForm) => {
  return request({
    url: '/front/frontUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改前台用户
 * @param data
 */
export const updateFrontUser = (data: FrontUserForm) => {
  return request({
    url: '/front/frontUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除前台用户
 * @param userId
 */
export const delFrontUser = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/front/frontUser/' + userId,
    method: 'delete'
  });
};
